#SIG HPC
#Pandemic Simulation
#Code for creation of the Grid object

#Grid object to represent the entire map
class Grid:
	#Constructor for Grid
	def __init__(self,rows,cols):
		self.grid = [] #Grid will be represented as a list of list. Each sublist will be a row in the grid matrix
		self.rows = rows
		self.cols = cols
		
		#Bruteforcing grid creation because I can't into Python
		i = 0
		while i < self.rows:
			j = 0
			tempList = []
	
			while j < self.cols:
				tempList.append(0)
				j = j + 1
		
			self.grid.append(tempList)
			i = i + 1
			
	#Populate the grid with unique data for debugging purposes		
	def populate(self):
		num = 1
		for item in self.grid:
			i = 0
			while i < self.cols:
				item[i] = num
				num = num + 1
	
				i = i + 1	
				
	#Print the grid for debugging purposes, results in a matrix-like form instead of a giant list of lists			
	def printGrid(self):
		for item in self.grid:
			print item
	
	#Return a grid object that represents a quadrant of the overall grid, will not scale if we ever want to use different sized areas
	#quadNum: 1 = top left quadrant, increasing the number clockwise for the remaining three quadrants
	def getQuad(self,quadNum):
		#Create a new grid of only half size on each dimension because quadrants
		quadrant = Grid(self.rows/2,self.cols/2)
		
		#Start and end points for where to pull data from the main grid from
		if quadNum == 1:
			rowStart = 0
			colStart = 0
			rowEnd = self.rows / 2
			colEnd = self.cols / 2
		elif quadNum == 2:
			rowStart = 0
			colStart = self.cols / 2
			rowEnd = self.rows / 2
			colEnd = self.cols
		elif quadNum == 3:
			rowStart = self.rows / 2
			colStart = 0
			rowEnd = self.rows
			colEnd = self.cols / 2
		elif quadNum == 4:
			rowStart = self.rows / 2
			colStart = self.cols / 2
			rowEnd = self.rows
			colEnd = self.cols			
		
		i = rowStart
		qrow = 0
		while i < rowEnd:
			j = colStart
			qcol = 0
			while j < colEnd:
				quadrant.grid[qrow][qcol] = self.grid[i][j]
				qcol = qcol + 1
				j = j + 1
			i = i + 1
			qrow = qrow + 1
				
		return quadrant
